package com.minhua.jijiehao2.mainframe.circle.productIdentifyActivity.impl

import com.minhua.jijiehao2.bean.BaseBean
import com.minhua.jijiehao2.http.*
import com.minhua.jijiehao2.mainframe.circle.productIdentifyActivity.imp.IProductIdentifyModel
import okhttp3.MultipartBody

class ProductIdentifyModel : IProductIdentifyModel {
    override fun upLoadProductInfo(map: ParamsMap, callBack: CallBack<Any>) {
        HttpController<Any>().doHttp(
                ApiClient.getInstance().api.upLoadProduct(map.toRequestBody()),
                object : BaseSubscriber<Any>() {
                    override fun dealData(t: BaseBean<Any>) {
                        super.dealData(t)
                        callBack.onSuccess(t)
                    }
                }
        )
    }

    override fun upLoadImage(multipart: MultipartBody.Part, callBack: CallBack<String>) {
        HttpController<String>().doHttp(
                NoTokenApiClient.getInstance().api.uploadImage(multipart),
                object : BaseSubscriber<String>() {
                    override fun dealData(t: BaseBean<String>) {
                        super.dealData(t)
                        callBack.onSuccess(t)
                    }
                }
        )
    }
}